package com.jaux.hotel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jaux.hotel.mapper.CourseMapper;
import com.jaux.hotel.pojo.Course;
import com.jaux.hotel.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author JAUX
 */

@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {
    @Autowired
    private CourseMapper courseMapper;

    /**
     * 添加课程
     * @param course 课程对象
     * @return 显示添加结果
     */
    @Override
    public String insertCourse(Course course) {
        int insert = courseMapper.insert(course);
        if (insert > 0){
           return "添加成功";
        }else {
            return "添加失败";
        }
    }

    /**
     * 通过课程名查询课程信息
     * @param courseName 课程名
     * @return 课程信息
     */
    @Override
    public List<Course> selectByInfo(String courseName) {
        LambdaQueryWrapper<Course> courseLambdaQueryWrapper = new LambdaQueryWrapper<>();
        courseLambdaQueryWrapper.eq(Course::getCourseName, courseName);
        return courseMapper.selectList(courseLambdaQueryWrapper);
    }
}
